﻿@model LoginUser
@{
    ViewBag.Title = "帝苑酒店点餐系统";
    List<System_Menu> pMenuList = ViewData["PMenu"] as List<System_Menu>;     //父菜单
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit" />
    <meta name="renderer" content="ie-stand" />
    <title>系统首页</title>
    <script>
        var menuJson = eval(@(Html.Raw(ViewData["MenuStr"].ToString())));
        var pMenuName="";
        function GetMenu(pMenuId,index) {
            var htmlStr = "<div class='nav-2 collapse' id='navItem-"+index+"'><ul>";
            for (var i = 0; i < menuJson.length; i++) {
                if (menuJson[i].pId == pMenuId) {   //父菜单
                    if (menuJson[i].typeId == 1) {
                        for (var j = 0; j < menuJson.length; j++) {
                            if (menuJson[j].pId == menuJson[i].id) {
                                htmlStr += '<li><a href="javascript:void(0)" onclick="redirectTo(\'' + menuJson[j].pUrl + '\',this)">' + menuJson[j].name + '</a></li>';
                            }
                        }
                    } else {
                        for (var k = 0; k < menuJson.length; k++) {
                            if (menuJson[k].id==menuJson[i].pId) {
                                pMenuName=menuJson[k].name;
                                htmlStr += '<li><a href="javascript:void(0)" parentMenu='+pMenuName+' onclick="redirectToNew(\'' + menuJson[i].pUrl + '\',this)"><i class="icon-caret-right icon-large margin10-r"></i>' +menuJson[i].name + '</a></li>';
                            }
                        }
                    }
                }
            }
            htmlStr += "</ul></div>";
            document.write(htmlStr);
        }
    </script>
</head>
<body style="overflow: hidden">
    <div class="container">
        <div class="top">
            <div class="logo">
                帝苑酒店点餐系统
            </div>
            <div class="info">
                <ul class="ul-1">
                    <li class="user">
                        <a class="" href="javascript:void(0);" onclick="redirectTo('/System/LoginUserInfoEdit?id='+@Model.UserId,this)" target="mainFrame">
                            <i class="icon-user icon-large"></i><span>@Model.Account</span>
                        </a>
                    </li>
                    <li>
                        <a href="@Url.Action("LogOut", "Home")" title="退出">
                            <i class="icon-off icon-large"></i>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="navigation">
            <div class="navigation-main">
                @*<h3 class="navigation-title"><i class="icon-home margin-r6"></i>功能菜单</h3>*@
                <div class="navigation-content">
                    <ul id="navCollapse">
                        @for (int i = 0; i < pMenuList.Count; i++)
                        {
                            if (pMenuList[i].ID == 1)//设置
                            {
                                <li class="accordion-group">
                                    <a class="nav-1" data-toggle="collapse" data-parent="#navCollapse" href="#navItem-@i" pmenu="@pMenuList[i].Menu_Name">
                                        <i class="@pMenuList[i].Pictures_Name margin-r6"></i>@pMenuList[i].Menu_Name
                                        @*<span></span><i class="icon-angle-down up-down"></i>*@
                                    </a>
                                    <script>
                                        GetMenu('@pMenuList[i].ID','@i');
                                    </script>
                                </li>
                            }
                            else
                            {
                                <li class="accordion-group">
                                    <a class="nav-1" data-toggle="collapse" data-parent="#navCollapse" href="#navItem-@i" pmenu="@pMenuList[i].Menu_Name" onclick="redirectTo('@pMenuList[i].Menu_Controller/@pMenuList[i].Menu_Action',this)">
                                        <i class="@pMenuList[i].Pictures_Name margin-r6"></i>@pMenuList[i].Menu_Name</a>
                                </li>
                            }
                        }
                    </ul>
                </div>
            </div>
        </div>
        <div class="nav-stretch" id="navStretch">
            @*<a href="##" id="navButton" title="收缩菜单" onclick="closeboxleft(1);">&nbsp;</a>*@
        </div>
        <div class="main">
            <div class="main-title">
                @*<img src="~/content/themes/default/images/icon-title.png" border="0" />*@
                <i class="icon-coffee"></i>
                <span id="spanTitle">点餐</span>
            </div>
            <div id="load" style="display: none">
                <div class="loading-bg"></div>
                <div class="loading">
                    <img src="~/Content/images/loading.gif" />
                    <span class="loading-text">
                        加载中...
                    </span>
                </div>
            </div>
            <iframe src="/Home/DefaultPage" class="iframe" id="mainFrame" name="mainFrame" frameborder="0" width="100%" height="100%" scrolling="true"></iframe>
        </div>
        <div class="clear"></div>
        <div class="bottom"></div>
    </div>
    <script>
        $(document).ready(function () {
            //加载框
            $("#load").show();
            var iframe = document.getElementById("mainFrame");
            if (iframe.attachEvent) {
                iframe.attachEvent("onload", function () {
                    $("#load").hide();
                });
            } else {
                iframe.onload = function () {
                    $("#load").hide();
                };
            }
            //退出系统
            $("#quit").click(function () {
                var url = '@Url.Action("LogOut", "Home")';
                $.ajax({
                    type: "get",
                    url: url,
                    data: "",
                    async: false,
                    success: function (msg) {
                        top.location.href = '../home/index';
                    }
                });
            });
            //滚动条样式
            $(".navigation-content").niceScroll({
                cursorcolor: "#999",
                cursorwidth: "6px",
                cursoropacitymin: "1",
                cursoropacitymax: "1"
            });
        });

        function redirectTo(src, a) {
            $(".hover").removeClass("hover");
            $("#spanTitle").html($(a).text());
            $("#mainFrame").attr("src", src);
            $(a).addClass("hover");
        }
        function redirectToNew(src, a){
            $(".active").removeClass("active");
            $("#spanTitle").html($(a).attr("parentMenu") + "&nbsp;<i class='icon-angle-right'></i>&nbsp;" + $(a).text());
            $("#mainFrame").attr("src", src);
            $(a).parent().addClass("active");
            //加载框
            $("#load").show();
            var iframe = document.getElementById("mainFrame");
            if (iframe.attachEvent) {
                iframe.attachEvent("onload", function () {
                    $("#load").hide();
                });
            } else {
                iframe.onload = function () {
                    $("#load").hide();
                };
            }
        }
        $(".nav-1").click(function () {
            $(".nav-1").removeClass("hover");
            $(this).addClass("hover");
        });
        //导航nav折叠
        function closeboxleft(v) {
            if (v == 1) {
                $(".navigation").fadeOut(300);
                $("#navStretch").addClass("nav-stretch2");
                $("#navStretch").html("<a id='navButton' title='展开菜单' onclick='closeboxleft(2);'></a>");
                $(".main").animate({ left: "10" }, "0.4");
                $(".main-title").animate({ left: "10" }, "0.4");

            } else {
                $(".navigation").fadeIn(300);
                $("#navStretch").removeClass("nav-stretch2");
                $(".main").animate({ left: "153px" }, "0.4");
                $(".main-title").animate({ left: "153px" }, "0.4");
                $("#navStretch").html("<a id='navButton' title='收起菜单' onclick='closeboxleft(1);' ></a>");
            }
        }
    </script>
</body>
</html>